#! /usr/bin/python3
# _*_ coding:UTF-8 _*_
"""
    请把下面的Student对象的gender字段对外隐藏起来，用get_gender()和set_gender()代替，并检查参数有效性：
"""


class Student(object):

    def __init__(self, name):
        self.__name = name
        self.__grade = ''

    def set_grade(self, grade):
        if grade in 'ABC':
            self.__grade = grade
            print('grade已经设置')
            return True
        else:
            print('设置的grade有误')
            return False

    def get_grade(self):
        print('%s的grade是%s' % (self.__name, self.__grade))


def main():
    wang = Student('王楠')
    while True:
        grade = input('请输入王楠的grade：')
        t_or_f = wang.set_grade(grade)
        if t_or_f:
            break
    wang.get_grade()


if __name__ == '__main__':
    main()
